package com.arethusa;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.BoxLayout;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JRViewer;

import org.gui.JCalendarCombo;

import simpleorm.core.SConnection;
import simpleorm.core.SPreparedStatement;
import simpleorm.core.SResultSet;
import simpleorm.core.SValidationException;

import com.arethusa.langebaandb.Funktie;
import com.arethusa.langebaandb.FunktieBean;
import com.arethusa.langebaandb.Procesverbaal;
import com.arethusa.langebaandb.ProcesverbaalBean;
import com.arethusa.langebaandb.StartkostenBean;
import com.arethusa.langebaandb.Wedstrijdjury;
import com.arethusa.langebaandb.WedstrijdjuryBean;
import com.ibm.j2x.swing.util.TableUtilities;
import com.ibm.j2x.util.CollectionUtilities;
import javax.swing.JDialog;

public class ProcesVerbaal extends JPanel {

	static final long serialVersionUID=1;
	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JTextField naamTextField = null;
	private JButton wijzigWedstrijdButton = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;
	private JLabel jLabel4 = null;
	private JLabel jLabel5 = null;
	private JLabel jLabel6 = null;
	private JLabel jLabel7 = null;
	private JLabel jLabel8 = null;
	private JLabel jLabel9 = null;
	private JLabel jLabel10 = null;
	private JLabel jLabel11 = null;
	private JTextField organisatieTextField = null;
	private JTextField startMethodeTextField = null;
	private JTextField tijdMetingTextField = null;
	private JTextField tempTextField = null;
	private JTextField zwemwaterTextField = null;
	private JTextField plaatsTextField = null;
	private JTextField baanLengteTextField = null;
	private JTextField aanvangTextField = null;
	private JTextField eindeTextField = null;
	private JTextField waarnemerTextField = null;
	private JButton invoerButton = null;
	private JButton verwijderButton = null;
	private JButton herstelButton = null;
	private JPanel jPanel1 = null;
	private JTextField idTextField = null;
	private JLabel jLabel17 = null;
	private JLabel jLabel18 = null;
	private JLabel jLabel19 = null;
	private JLabel jLabel20 = null;
	private JTextField naamJuryTextField = null;
	private JTextField plaatsJuryTextField = null;
	private JTextField bevoegdheidTextField = null;
	private JComboBox funktieComboBox = null;
	private JScrollPane jScrollPane = null;
	private JTable jTable = null;
	private JButton wijzigButton = null;
	private JCalendarCombo datumField = null;
	
	private List<WedstrijdjuryBean> olist;
	private String sortBy = "seqnr";  //  @jve:decl-index=0:
	private Boolean sortAscending = new Boolean(true);
	private Integer wedId = null;  //  @jve:decl-index=0:
	private JLabel jLabel14 = null;
	private JLabel jLabel221 = null;
	private JTextField AfwezigMKTextField = null;
	private JLabel jLabel222 = null;
	private JTextField AfwezigZKTextField = null;
	private JButton printButton = null;
	private JPanel prvwPanel = null;
	private JScrollPane opmerkingenScrollPane = null;
	private JTextArea opmerkingenTextArea = null;
	private JButton clearButton = null;
	private JLabel jLabel12 = null;
	private JTextField blokNrTextField = null;
	private JButton startKostenButton = null;
	private JDialog startkostenDialog = null;  //  @jve:decl-index=0:visual-constraint="0,690"
	private JPanel jContentPane = null;
	private JPanel okCancelPanel = null;
	private JPanel entryPanel = null;
	private JButton okButton = null;
	private JButton cancelButton = null;
	private JTextField label1TextField = null;
	private JTextField value1TextField = null;
	private JTextField label2TextField = null;
	private JTextField value2TextField = null;
	private JTextField label3TextField = null;
	private JTextField value3TextField = null;
	private JTextField label4TextField = null;
	private JTextField value4TextField = null;
	private JTextField label5TextField = null;
	private JTextField value5TextField = null;
	
	private class WijzigWedstrijdButtonActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			ProcesverbaalBean cur = new ProcesverbaalBean();
			cur.setWedstrijdid(wedId);
			try {
				cur.setWedstrijdnaam(naamTextField.getText());
				cur.setOrganisatie(organisatieTextField.getText());
				cur.setZwembad(zwemwaterTextField.getText());
				cur.setPlaats(plaatsTextField.getText());
				
				Calendar c = Calendar.getInstance();
				c = datumField.getDate();
				c.add(Calendar.MONTH,-1); // Correctie omdat de getTime functie er een maand bij optelt
				cur.setWedstrijddatum(c.getTime());
				
				cur.setBaanlengte(new Integer(baanLengteTextField.getText()));
				cur.setStartmethode(startMethodeTextField.getText());
				cur.setTijdmeting(tijdMetingTextField.getText());
				cur.setWatertemperatuur(new BigDecimal(tempTextField.getText()));
				String[] t = aanvangTextField.getText().split(":");
				long tm = 0L;
				tm = (new Long(t[0]).longValue()-1)*3600 + new Long(t[1]).longValue()*60;
				cur.setAanvang(new Time(tm*1000));
				t = eindeTextField.getText().split(":");
				tm = (new Long(t[0]).longValue()-1)*3600 + new Long(t[1]).longValue()*60;
				cur.setEinde(new Time(tm*1000));
				cur.setWaarnemer(waarnemerTextField.getText());
				cur.setAfwezigmk(new Integer(new Integer(AfwezigMKTextField.getText()).intValue()));
				cur.setAfwezigzk(new Integer(new Integer(AfwezigZKTextField.getText()).intValue()));
				cur.setOpmerkingen(opmerkingenTextArea.getText());
				cur.update();
				getWedstrijd();
				fillTable(sortBy, sortAscending);
				clearInvoer();
			} catch (SValidationException e1) {
				JOptionPane.showMessageDialog(null,
					e1.getMessage(),
					"Validatie", JOptionPane.ERROR_MESSAGE);
			} catch (NumberFormatException e2) {
				JOptionPane.showMessageDialog(null,
					e2.getMessage(),
					"Validatie", JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	
	private class PrintButtonActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			PrintPreviewDialog prvw = new PrintPreviewDialog();
			Map<String,String> parms = new HashMap<String,String>();
			parms.put("AfwezigMK", getAfwezigMKTextField().getText());
			parms.put("AfwezigZK", getAfwezigZKTextField().getText());
			
			JasperPrint prt = new JasperPrint();
			try {
				boolean hasBegun = SConnection.getConnection().hasBegun();
				if( ! hasBegun ) { SConnection.begin(); }
				prt = JasperFillManager.fillReport("reports\\ProcesVerbaal.jasper", parms, SConnection.getBegunDBConnection());
				SConnection.commit();
			} catch (JRException re) {
				JOptionPane.showMessageDialog(null,
						re.getMessage()+re.getCause(),
						"Report foutmelding", JOptionPane.ERROR_MESSAGE);
			}
			if( prvwPanel != null) prvw.getContentPane().remove(prvwPanel);
			prvwPanel = new JRViewer(prt);
			prvw.getContentPane().add(prvwPanel, java.awt.BorderLayout.CENTER);
			prvw.setSize(800,950);
			prvw.setVisible(true);
		}
		
	}
	
	private class StartKostenActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			StartkostenBean k = new StartkostenBean();
			k.setWedstrijdid(wedId);
			k.read();
			if( k.getLabelstart1()!=null && k.getLabelstart1().length() !=0 ) {
				getLabel1TextField().setText(k.getLabelstart1());
				getValue1TextField().setText(k.getKostenstart1().toString());
			}
			if( k.getLabelstart2()!=null && k.getLabelstart2().length() !=0 ) {
				getLabel2TextField().setText(k.getLabelstart2());
				getValue2TextField().setText(k.getKostenstart2().toString());
			}
			if( k.getLabelstart3()!=null && k.getLabelstart3().length() !=0 ) {
				getLabel3TextField().setText(k.getLabelstart3());
				getValue3TextField().setText(k.getKostenstart3().toString());
			}
			if( k.getLabelstart4()!=null && k.getLabelstart4().length() !=0 ) {
				getLabel4TextField().setText(k.getLabelstart4());
				getValue4TextField().setText(k.getKostenstart4().toString());
			}
			if( k.getLabelstart5()!=null && k.getLabelstart5().length() !=0 ) {
				getLabel5TextField().setText(k.getLabelstart5());
				getValue5TextField().setText(k.getKostenstart5().toString());
			}
			getStartkostenDialog().setVisible(true);
		}
		
	}
	
	private class SaveStartkostenActionListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			StartkostenBean k = new StartkostenBean();
			k.setWedstrijdid(wedId);
			k.read();
			if( getLabel1TextField().getText()!=null && getLabel1TextField().getText().length() !=0 ) {
				k.setLabelstart1(getLabel1TextField().getText());
				k.setKostenstart1(new BigDecimal(getValue1TextField().getText()));
			}
			if( getLabel2TextField().getText()!=null && getLabel2TextField().getText().length() !=0 ) {
				k.setLabelstart2(getLabel2TextField().getText());
				k.setKostenstart2(new BigDecimal(getValue2TextField().getText()));
			}
			if( getLabel3TextField().getText()!=null && getLabel3TextField().getText().length() !=0 ) {
				k.setLabelstart3(getLabel3TextField().getText());
				k.setKostenstart3(new BigDecimal(getValue3TextField().getText()));
			}
			if( getLabel4TextField().getText()!=null && getLabel4TextField().getText().length() !=0 ) {
				k.setLabelstart4(getLabel4TextField().getText());
				k.setKostenstart4(new BigDecimal(getValue4TextField().getText()));
			}
			if( getLabel5TextField().getText()!=null && getLabel5TextField().getText().length() !=0 ) {
				k.setLabelstart5(getLabel5TextField().getText());
				k.setKostenstart5(new BigDecimal(getValue5TextField().getText()));
			}
			k.update();
			getStartkostenDialog().setVisible(false);
		}
		
	}
	
	private class InvoerButtonActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			WedstrijdjuryBean cur = new WedstrijdjuryBean();
			try {
				Long seqnr;
				FunktieBean f = (FunktieBean) funktieComboBox.getSelectedItem();
				cur.setId(new Long(0));
				String bloknr = blokNrTextField.getText();
				if( bloknr == null || bloknr.length() == 0) {
					seqnr = f.getSeqnr();
				} else {
					seqnr = f.getSeqnr()+Long.parseLong(bloknr)*10;
				}
				cur.setFunktie(f.getNaam());
				cur.setCode(f.getCode());
				cur.setSeqnr(seqnr);
				cur.setNaam(naamJuryTextField.getText());
				cur.setPlaats(plaatsJuryTextField.getText());
				cur.setBevoegdheid(bevoegdheidTextField.getText());
				cur.setBloknr(bloknr);
				cur.create();
				fillTable(sortBy, sortAscending);
				clearInvoer();
			} catch (SValidationException e) {
				JOptionPane.showMessageDialog(null,
						e.getMessage(),
						"Validatie", JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	
	private class WijzigButtonActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			Long seqnr;
			WedstrijdjuryBean cur = new WedstrijdjuryBean();
			FunktieBean f = (FunktieBean) funktieComboBox.getSelectedItem();
			cur.setId(new Long(idTextField.getText()));
			String bloknr = blokNrTextField.getText();
			if( bloknr == null || bloknr.length() == 0) {
				seqnr = f.getSeqnr();
			} else {
				seqnr = f.getSeqnr()+Long.parseLong(bloknr)*10;
			}
			cur.setFunktie(f.getNaam());
			cur.setCode(f.getCode());
			cur.setSeqnr(seqnr);
			cur.setNaam(naamJuryTextField.getText());
			cur.setPlaats(plaatsJuryTextField.getText());
			cur.setBevoegdheid(bevoegdheidTextField.getText());
			cur.setBloknr(bloknr);
			try {
				cur.update();
				fillTable(sortBy, sortAscending);
				clearInvoer();
			} catch (SValidationException e) {
				JOptionPane.showMessageDialog(null,
						e.getMessage(),
						"Validatie", JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	
	private class VerwijderButtonActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			if(JOptionPane.showConfirmDialog(null,
					"Zeker weten?","Verwijderen",
					JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_CANCEL_OPTION ) return;
			WedstrijdjuryBean cur = new WedstrijdjuryBean();
			cur.setId(new Long(idTextField.getText()));
			try {
				cur.delete();
				fillTable(sortBy, sortAscending);
				clearInvoer();
			} catch (SValidationException e) {
				JOptionPane.showMessageDialog(null,
						e.getMessage(),
						"Validatie", JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	
	private class ClearButtonActionListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			if(JOptionPane.showConfirmDialog(null,
					"Zeker weten?","Leeg maken",
					JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_CANCEL_OPTION ) return;
			boolean hasBegun = SConnection.getConnection().hasBegun();
			if( ! hasBegun ) { SConnection.begin(); }
			SConnection.rawUpdateDB("DELETE FROM WedstrijdJury");
			SConnection.rawUpdateDB("ALTER TABLE WedstrijdJury AUTO_INCREMENT = 1");
			SConnection.commit();
			fillTable(sortBy, sortAscending);
			clearInvoer();
		}
	}
	
	private class TableSelectionListener implements ListSelectionListener {
	    public void valueChanged(ListSelectionEvent e) {
	        //Ignore extra messages.
	        if (e.getValueIsAdjusting()) return;

	        ListSelectionModel lsm = (ListSelectionModel)e.getSource();
	        if (lsm.isSelectionEmpty()) {
	            //no rows are selected
	        } else {
	            int selectedRow = lsm.getMinSelectionIndex();
	            //selectedRow is selected
	            WedstrijdjuryBean r = (WedstrijdjuryBean)olist.get(selectedRow);
	        	getIdTextField().setText(r.getId().toString());
	        	getIdTextField().setEnabled(false);
	    		getNaamJuryTextField().setText(r.getNaam());
	    		getPlaatsJuryTextField().setText(r.getPlaats());
	    		getBevoegdheidTextField().setText(r.getBevoegdheid());
    			getBlokNrTextField().setText(r.getBloknr());
	    		
	    		FunktieBean f = new FunktieBean();
	    		Long seqnr;
				String bloknr = r.getBloknr();
				if( bloknr == null || bloknr.length() == 0) {
					seqnr = r.getSeqnr();
					getBlokNrTextField().setEnabled(false);
					f.setBlok(false);
				} else {
					seqnr = r.getSeqnr()-Long.parseLong(bloknr)*10;
					getBlokNrTextField().setEnabled(true);
					f.setBlok(true);
				}
	    		f.setCode(r.getCode());
	    		f.setNaam(r.getFunktie());
	    		f.setSeqnr(seqnr);
	    		getFunktieComboBox().getModel().setSelectedItem(f);
	        }
	    }
	}
	
	private class FunktieSelectionListener implements ActionListener {

		public void actionPerformed(ActionEvent ae) {
			FunktieBean f = (FunktieBean) getFunktieComboBox().getSelectedItem();
			if( !f.getBlok() ) {
				getBlokNrTextField().setEnabled(false);
				getBlokNrTextField().setText("");
			} else {
				getBlokNrTextField().setEnabled(true);
			}
			getFunktieComboBox().getModel().setSelectedItem(f);
		}
	}
	
	private class TableSorter extends MouseAdapter {
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = jTable.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = jTable.convertColumnIndexToModel(viewColumn); 
            if(e.getClickCount() == 1 && column != -1) {
                sortAscending = new Boolean(!sortAscending.booleanValue());
                sortBy = jTable.getModel().getColumnName(column);
                fillTable(sortBy, sortAscending);
                clearInvoer();
            }
         }
	}

	/**
	 * This is the default constructor
	 */
	public ProcesVerbaal() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setLayout(new BorderLayout());
		this.setSize(614, 648);
		this.add(getJPanel(), java.awt.BorderLayout.NORTH);
		this.add(getJPanel1(), java.awt.BorderLayout.CENTER);
		getWedstrijd();
		fillTable("Seqnr", new Boolean(true));
	}
	
	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing jPanel
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
			gridBagConstraints13.gridx = 4;
			gridBagConstraints13.insets = new Insets(3, 3, 3, 3);
			gridBagConstraints13.fill = GridBagConstraints.BOTH;
			gridBagConstraints13.gridy = 2;
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.fill = GridBagConstraints.BOTH;
			gridBagConstraints2.gridy = 15;
			gridBagConstraints2.weightx = 1.0;
			gridBagConstraints2.weighty = 1.0;
			gridBagConstraints2.gridwidth = 4;
			gridBagConstraints2.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints2.ipady = 60;
			gridBagConstraints2.gridx = 0;
			GridBagConstraints gridBagConstraints112 = new GridBagConstraints();
			gridBagConstraints112.gridx = 4;
			gridBagConstraints112.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints112.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints112.gridy = 1;
			GridBagConstraints gridBagConstraints110 = new GridBagConstraints();
			gridBagConstraints110.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints110.gridy = 14;
			gridBagConstraints110.weightx = 1.0;
			gridBagConstraints110.weighty = 1.0;
			gridBagConstraints110.gridwidth = 4;
			gridBagConstraints110.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints110.gridx = 0;
			GridBagConstraints gridBagConstraints48 = new GridBagConstraints();
			gridBagConstraints48.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints48.gridy = 13;
			gridBagConstraints48.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints48.gridx = 3;
			GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
			gridBagConstraints47.gridx = 2;
			gridBagConstraints47.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints47.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints47.gridy = 13;
			jLabel222 = new JLabel();
			jLabel222.setText("Aantal afwezig zk");
			GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
			gridBagConstraints46.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints46.gridy = 13;
			gridBagConstraints46.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints46.gridx = 1;
			GridBagConstraints gridBagConstraints451 = new GridBagConstraints();
			gridBagConstraints451.gridx = 0;
			gridBagConstraints451.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints451.gridy = 13;
			jLabel221 = new JLabel();
			jLabel221.setText("Aantal afwezig mk");
			GridBagConstraints gridBagConstraints441 = new GridBagConstraints();
			gridBagConstraints441.gridx = 0;
			gridBagConstraints441.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints441.gridwidth = 4;
			gridBagConstraints441.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints441.gridy = 14;
			jLabel14 = new JLabel();
			jLabel14.setText("Opmerkingen scheidsrechter");
			GridBagConstraints gridBagConstraints431 = new GridBagConstraints();
			gridBagConstraints431.gridx = 1;
			gridBagConstraints431.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints431.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints431.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints431.weightx = 1.0D;
			gridBagConstraints431.gridy = 1;
			GridBagConstraints gridBagConstraints30 = new GridBagConstraints();
			gridBagConstraints30.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints30.gridy = 13;
			gridBagConstraints30.weighty = 1.0;
			gridBagConstraints30.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints30.gridwidth = 4;
			gridBagConstraints30.ipady = 50;
			gridBagConstraints30.anchor = java.awt.GridBagConstraints.NORTH;
			gridBagConstraints30.gridx = 0;
			GridBagConstraints gridBagConstraints26 = new GridBagConstraints();
			gridBagConstraints26.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints26.gridy = 9;
			gridBagConstraints26.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints26.gridx = 3;
			GridBagConstraints gridBagConstraints25 = new GridBagConstraints();
			gridBagConstraints25.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints25.gridy = 11;
			gridBagConstraints25.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints25.gridx = 3;
			GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
			gridBagConstraints24.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints24.gridy = 11;
			gridBagConstraints24.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints24.gridx = 1;
			GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
			gridBagConstraints22.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints22.gridy = 5;
			gridBagConstraints22.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints22.gridx = 1;
			GridBagConstraints gridBagConstraints211 = new GridBagConstraints();
			gridBagConstraints211.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints211.gridy = 3;
			gridBagConstraints211.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints211.gridx = 3;
			GridBagConstraints gridBagConstraints20 = new GridBagConstraints();
			gridBagConstraints20.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints20.gridy = 3;
			gridBagConstraints20.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints20.gridx = 1;
			GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
			gridBagConstraints19.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints19.gridy = 5;
			gridBagConstraints19.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints19.gridx = 3;
			GridBagConstraints gridBagConstraints18 = new GridBagConstraints();
			gridBagConstraints18.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints18.gridy = 2;
			gridBagConstraints18.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints18.gridx = 3;
			GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
			gridBagConstraints17.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints17.gridy = 2;
			gridBagConstraints17.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints17.gridx = 1;
			GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
			gridBagConstraints16.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints16.gridy = 1;
			gridBagConstraints16.weightx = 1.0;
			gridBagConstraints16.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints16.gridx = 3;
			GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
			gridBagConstraints14.gridx = 0;
			gridBagConstraints14.gridwidth = 4;
			gridBagConstraints14.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints14.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints14.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints14.gridy = 14;
			GridBagConstraints gridBagConstraints111 = new GridBagConstraints();
			gridBagConstraints111.gridx = 2;
			gridBagConstraints111.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints111.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints111.gridy = 9;
			jLabel11 = new JLabel();
			jLabel11.setText("Waarnemer");
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
			gridBagConstraints10.gridx = 2;
			gridBagConstraints10.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints10.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints10.gridy = 11;
			jLabel10 = new JLabel();
			jLabel10.setText("Einde wedstrijd");
			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
			gridBagConstraints9.gridx = 0;
			gridBagConstraints9.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints9.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints9.gridy = 11;
			jLabel9 = new JLabel();
			jLabel9.setText("Aanvang wedstrijd");
			GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
			gridBagConstraints8.gridx = 0;
			gridBagConstraints8.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints8.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints8.gridy = 5;
			jLabel8 = new JLabel();
			jLabel8.setText("Baanlengte");
			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
			gridBagConstraints7.gridx = 2;
			gridBagConstraints7.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints7.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints7.gridy = 3;
			jLabel7 = new JLabel();
			jLabel7.setText("Plaats");
			GridBagConstraints gridBagConstraints61 = new GridBagConstraints();
			gridBagConstraints61.gridx = 0;
			gridBagConstraints61.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints61.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints61.gridy = 3;
			jLabel6 = new JLabel();
			jLabel6.setText("Zwemwater");
			GridBagConstraints gridBagConstraints51 = new GridBagConstraints();
			gridBagConstraints51.gridx = 2;
			gridBagConstraints51.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints51.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints51.gridy = 5;
			jLabel5 = new JLabel();
			jLabel5.setText("Watertemperatuur");
			GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
			gridBagConstraints41.gridx = 2;
			gridBagConstraints41.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints41.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints41.gridy = 2;
			jLabel4 = new JLabel();
			jLabel4.setText("Tijdmeting");
			GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
			gridBagConstraints31.gridx = 0;
			gridBagConstraints31.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints31.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints31.gridy = 2;
			jLabel3 = new JLabel();
			jLabel3.setText("Startmethode");
			GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
			gridBagConstraints21.gridx = 2;
			gridBagConstraints21.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints21.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints21.gridy = 1;
			jLabel2 = new JLabel();
			jLabel2.setText("Organisatie");
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints11.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints11.gridy = 1;
			jLabel1 = new JLabel();
			jLabel1.setText("Datum");
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 4;
			gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints4.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints4.gridy = 0;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints1.gridy = 0;
			gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints1.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints1.gridwidth = 3;
			gridBagConstraints1.gridx = 1;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints.gridy = 0;
			GridBagConstraints gridBagConstraints32 = new GridBagConstraints();
			gridBagConstraints32.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints32.gridy = 1;
			gridBagConstraints32.weightx = 1.0;
			gridBagConstraints32.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints32.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints32.gridx = 3;
			jLabel = new JLabel();
			jLabel.setText("Naam");
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			jPanel.add(getWijzigWedstrijdButton(), gridBagConstraints4);
			jPanel.add(getPrintButton(), gridBagConstraints112);
			jPanel.add(jLabel, gridBagConstraints);
			jPanel.add(jLabel1, gridBagConstraints11);
			jPanel.add(jLabel2, gridBagConstraints21);
			jPanel.add(jLabel3, gridBagConstraints31);
			jPanel.add(jLabel4, gridBagConstraints41);
			jPanel.add(jLabel5, gridBagConstraints51);
			jPanel.add(jLabel6, gridBagConstraints61);
			jPanel.add(jLabel7, gridBagConstraints7);
			jPanel.add(jLabel8, gridBagConstraints8);
			jPanel.add(jLabel9, gridBagConstraints9);
			jPanel.add(jLabel10, gridBagConstraints10);
			jPanel.add(jLabel11, gridBagConstraints111);
			jPanel.add(jLabel14, gridBagConstraints441);
			jPanel.add(jLabel221, gridBagConstraints451);
			jPanel.add(jLabel222, gridBagConstraints47);
			jPanel.add(getNaamTextField(), gridBagConstraints1);
			jPanel.add(getOrganisatieTextField(), gridBagConstraints16);
			jPanel.add(getDatumField(), gridBagConstraints431);
			jPanel.add(getStartMethodeTextField(), gridBagConstraints17);
			jPanel.add(getTijdMetingTextField(), gridBagConstraints18);
			jPanel.add(getTempTextField(), gridBagConstraints19);
			jPanel.add(getZwemwaterTextField(), gridBagConstraints20);
			jPanel.add(getPlaatsTextField(), gridBagConstraints211);
			jPanel.add(getBaanLengteTextField(), gridBagConstraints22);
			jPanel.add(getAanvangTextField(), gridBagConstraints24);
			jPanel.add(getEindeTextField(), gridBagConstraints25);
			jPanel.add(getWaarnemerTextField(), gridBagConstraints26);
			jPanel.add(getAfwezigZKTextField(), gridBagConstraints48);
			jPanel.add(getAfwezigMKTextField(), gridBagConstraints46);
			jPanel.add(getOpmerkingenScrollPane(), gridBagConstraints2);
			jPanel.add(getStartKostenButton(), gridBagConstraints13);
		}
		return jPanel;
	}

	/**
	 * This method initializes wijzigButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getWijzigWedstrijdButton() {
		if (wijzigWedstrijdButton == null) {
			wijzigWedstrijdButton = new JButton();
			wijzigWedstrijdButton.setText("Wijzig");
			wijzigWedstrijdButton.addActionListener(new WijzigWedstrijdButtonActionListener());
		}
		return wijzigWedstrijdButton;
	}
	
	/**
	 * This method initializes printButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getPrintButton() {
		if (printButton == null) {
			printButton = new JButton();
			printButton.setText("Print");
			printButton.addActionListener(new PrintButtonActionListener());
		}
		return printButton;
	}
	/**
	 * This method initializes progNrTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNaamTextField() {
		if (naamTextField == null) {
			naamTextField = new JTextField();
		}
		return naamTextField;
	}

	/**
	 * This method initializes datumField	
	 * 	
	 * @return javax.swing.JCalendar	
	 */
	private JCalendarCombo getDatumField() {
		if (datumField == null) {
			datumField = new JCalendarCombo(JCalendarCombo.MONDAY,true,2000,2100,false);
		}
		return datumField;
	}

	/**
	 * This method initializes organisatieTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getOrganisatieTextField() {
		if (organisatieTextField == null) {
			organisatieTextField = new JTextField();
		}
		return organisatieTextField;
	}

	/**
	 * This method initializes startMethodeTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getStartMethodeTextField() {
		if (startMethodeTextField == null) {
			startMethodeTextField = new JTextField();
		}
		return startMethodeTextField;
	}

	/**
	 * This method initializes tijdMetingTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTijdMetingTextField() {
		if (tijdMetingTextField == null) {
			tijdMetingTextField = new JTextField();
		}
		return tijdMetingTextField;
	}

	/**
	 * This method initializes tempTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTempTextField() {
		if (tempTextField == null) {
			tempTextField = new JTextField();
		}
		return tempTextField;
	}

	/**
	 * This method initializes zwemwaterTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getZwemwaterTextField() {
		if (zwemwaterTextField == null) {
			zwemwaterTextField = new JTextField();
		}
		return zwemwaterTextField;
	}

	/**
	 * This method initializes plaatsTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getPlaatsTextField() {
		if (plaatsTextField == null) {
			plaatsTextField = new JTextField();
		}
		return plaatsTextField;
	}

	/**
	 * This method initializes baanLengteTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getBaanLengteTextField() {
		if (baanLengteTextField == null) {
			baanLengteTextField = new JTextField();
		}
		return baanLengteTextField;
	}

	/**
	 * This method initializes aanvangTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getAanvangTextField() {
		if (aanvangTextField == null) {
			aanvangTextField = new JTextField();
		}
		return aanvangTextField;
	}

	/**
	 * This method initializes eindeTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getEindeTextField() {
		if (eindeTextField == null) {
			eindeTextField = new JTextField();
		}
		return eindeTextField;
	}

	/**
	 * This method initializes waarnemerTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getWaarnemerTextField() {
		if (waarnemerTextField == null) {
			waarnemerTextField = new JTextField();
		}
		return waarnemerTextField;
	}

	/**
	 * This method initializes AantalMKTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getAfwezigMKTextField() {
		if (AfwezigMKTextField == null) {
			AfwezigMKTextField = new JTextField();
			AfwezigMKTextField.setEditable(false);
		}
		return AfwezigMKTextField;
	}

	/**
	 * This method initializes AfwezigZKTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getAfwezigZKTextField() {
		if (AfwezigZKTextField == null) {
			AfwezigZKTextField = new JTextField();
			AfwezigZKTextField.setEditable(false);
		}
		return AfwezigZKTextField;
	}

	/**
	 * This method initializes opmerkingenScrollPane1	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getOpmerkingenScrollPane() {
		if (opmerkingenScrollPane == null) {
			opmerkingenScrollPane = new JScrollPane();
			opmerkingenScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			opmerkingenScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			opmerkingenScrollPane.setViewportView(getOpmerkingenTextArea());
		}
		return opmerkingenScrollPane;
	}

	/**
	 * This method initializes opmerkingenTextArea1	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getOpmerkingenTextArea() {
		if (opmerkingenTextArea == null) {
			opmerkingenTextArea = new JTextArea();
			opmerkingenTextArea.setColumns(1);
			opmerkingenTextArea.setRows(1);
		}
		return opmerkingenTextArea;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getInvoerButton() {
		if (invoerButton == null) {
			invoerButton = new JButton();
			invoerButton.setText("Voer in");
			invoerButton.addActionListener(new InvoerButtonActionListener());
		}
		return invoerButton;
	}

	/**
	 * This method initializes wijzigButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getWijzigButton() {
		if (wijzigButton == null) {
			wijzigButton = new JButton();
			wijzigButton.setText("Wijzig");
			wijzigButton.addActionListener(new WijzigButtonActionListener());
		}
		return wijzigButton;
	}
	
	/**
	 * This method initializes verwijderButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getVerwijderButton() {
		if (verwijderButton == null) {
			verwijderButton = new JButton();
			verwijderButton.setText("Verwijder");
			verwijderButton.addActionListener(new VerwijderButtonActionListener());
		}
		return verwijderButton;
	}

	/**
	 * This method initializes herstelButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getHerstelButton() {
		if (herstelButton == null) {
			herstelButton = new JButton();
			herstelButton.setText("Herstel");
			herstelButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					clearInvoer();
				}
			});
		}
		return herstelButton;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints12.gridy = 0;
			gridBagConstraints12.weightx = 1.0;
			gridBagConstraints12.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints12.ipadx = 20;
			gridBagConstraints12.anchor = GridBagConstraints.WEST;
			gridBagConstraints12.gridx = 3;
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 2;
			gridBagConstraints3.anchor = GridBagConstraints.EAST;
			gridBagConstraints3.insets = new Insets(3, 3, 3, 3);
			gridBagConstraints3.gridy = 0;
			jLabel12 = new JLabel();
			jLabel12.setText("Blok");
			GridBagConstraints gridBagConstraints49 = new GridBagConstraints();
			gridBagConstraints49.gridx = 0;
			gridBagConstraints49.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints49.gridy = 3;
			GridBagConstraints gridBagConstraints33 = new GridBagConstraints();
			gridBagConstraints33.gridx = 4;
			gridBagConstraints33.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints33.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints33.gridy = 1;
			GridBagConstraints gridBagConstraints36 = new GridBagConstraints();
			gridBagConstraints36.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints36.gridy = 5;
			gridBagConstraints36.weightx = 1.0;
			gridBagConstraints36.weighty = 1.0;
			gridBagConstraints36.gridwidth = 5;
			gridBagConstraints36.gridx = 0;
			GridBagConstraints gridBagConstraints45 = new GridBagConstraints();
			gridBagConstraints45.fill = GridBagConstraints.BOTH;
			gridBagConstraints45.gridy = 0;
			gridBagConstraints45.weightx = 1.0;
			gridBagConstraints45.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints45.gridwidth = 1;
			gridBagConstraints45.gridx = 1;
			GridBagConstraints gridBagConstraints44 = new GridBagConstraints();
			gridBagConstraints44.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints44.gridy = 2;
			gridBagConstraints44.weightx = 1.0;
			gridBagConstraints44.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints44.gridx = 1;
			GridBagConstraints gridBagConstraints43 = new GridBagConstraints();
			gridBagConstraints43.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints43.gridy = 1;
			gridBagConstraints43.weightx = 1.0;
			gridBagConstraints43.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints43.gridx = 3;
			GridBagConstraints gridBagConstraints42 = new GridBagConstraints();
			gridBagConstraints42.gridy = 1;
			gridBagConstraints42.weightx = 1.0;
			gridBagConstraints42.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints42.anchor = java.awt.GridBagConstraints.WEST;
			gridBagConstraints42.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints42.gridx = 1;
			GridBagConstraints gridBagConstraints38 = new GridBagConstraints();
			gridBagConstraints38.gridx = 0;
			gridBagConstraints38.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints38.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints38.gridy = 2;
			jLabel20 = new JLabel();
			jLabel20.setText("Bevoegdheid");
			GridBagConstraints gridBagConstraints37 = new GridBagConstraints();
			gridBagConstraints37.gridx = 2;
			gridBagConstraints37.anchor = GridBagConstraints.EAST;
			gridBagConstraints37.insets = new Insets(3, 3, 3, 3);
			gridBagConstraints37.gridy = 1;
			jLabel19 = new JLabel();
			jLabel19.setText("Plaats");
			GridBagConstraints gridBagConstraints35 = new GridBagConstraints();
			gridBagConstraints35.gridx = 0;
			gridBagConstraints35.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints35.anchor = java.awt.GridBagConstraints.EAST;
			gridBagConstraints35.gridy = 1;
			jLabel18 = new JLabel();
			jLabel18.setText("Naam");
			GridBagConstraints gridBagConstraints34 = new GridBagConstraints();
			gridBagConstraints34.gridx = 0;
			gridBagConstraints34.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints34.anchor = GridBagConstraints.EAST;
			gridBagConstraints34.gridy = 0;
			jLabel17 = new JLabel();
			jLabel17.setText("Funktie");
			GridBagConstraints gridBagConstraints32 = new GridBagConstraints();
			gridBagConstraints32.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints32.gridx = 4;
			gridBagConstraints32.gridy = 3;
			gridBagConstraints32.insets = new java.awt.Insets(3,3,3,3);
			GridBagConstraints gridBagConstraints29 = new GridBagConstraints();
			gridBagConstraints29.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints29.gridx = 4;
			gridBagConstraints29.gridy = 2;
			gridBagConstraints29.insets = new java.awt.Insets(3,3,3,3);
			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
			gridBagConstraints6.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints6.gridx = 4;
			gridBagConstraints6.gridy = 0;
			gridBagConstraints6.insets = new java.awt.Insets(3,3,3,3);
			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
			gridBagConstraints5.gridx = 3;
			gridBagConstraints5.gridy = 1;
			gridBagConstraints5.weightx = 1.0;
			gridBagConstraints5.insets = new java.awt.Insets(3,3,3,3);
			gridBagConstraints5.anchor = GridBagConstraints.EAST;
			gridBagConstraints5.ipadx = 20;
			gridBagConstraints5.fill = java.awt.GridBagConstraints.VERTICAL;
			jPanel1 = new JPanel();
			jPanel1.setLayout(new GridBagLayout());
			jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.black,2), "Jury samenstelling", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
			jPanel1.add(getInvoerButton(), gridBagConstraints6);
			jPanel1.add(getWijzigButton(), gridBagConstraints33);
			jPanel1.add(getVerwijderButton(), gridBagConstraints29);
			jPanel1.add(getHerstelButton(), gridBagConstraints32);
			jPanel1.add(jLabel17, gridBagConstraints34);
			jPanel1.add(jLabel18, gridBagConstraints35);
			jPanel1.add(jLabel19, gridBagConstraints37);
			jPanel1.add(jLabel20, gridBagConstraints38);
			jPanel1.add(getIdTextField(), gridBagConstraints5);
			jPanel1.add(getNaamJuryTextField(), gridBagConstraints42);
			jPanel1.add(getPlaatsJuryTextField(), gridBagConstraints43);
			jPanel1.add(getBevoegdheidTextField(), gridBagConstraints44);
			jPanel1.add(getFunktieComboBox(), gridBagConstraints45);
			jPanel1.add(getJScrollPane(), gridBagConstraints36);
			jPanel1.add(getClearButton(), gridBagConstraints49);
			jPanel1.add(jLabel12, gridBagConstraints3);
			jPanel1.add(getBlokNrTextField(), gridBagConstraints12);
		}
		return jPanel1;
	}

	/**
	 * This method initializes idTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getIdTextField() {
		if (idTextField == null) {
			idTextField = new JTextField();
			idTextField.setEnabled(false);
			idTextField.setVisible(false);
		}
		return idTextField;
	}

	/**
	 * This method initializes naamJuryTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNaamJuryTextField() {
		if (naamJuryTextField == null) {
			naamJuryTextField = new JTextField();
		}
		return naamJuryTextField;
	}

	/**
	 * This method initializes plaatsJuryTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getPlaatsJuryTextField() {
		if (plaatsJuryTextField == null) {
			plaatsJuryTextField = new JTextField();
		}
		return plaatsJuryTextField;
	}

	/**
	 * This method initializes bevoegdheidTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getBevoegdheidTextField() {
		if (bevoegdheidTextField == null) {
			bevoegdheidTextField = new JTextField();
		}
		return bevoegdheidTextField;
	}

	/**
	 * This method initializes funktieComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getFunktieComboBox() {
		if (funktieComboBox == null) {
			funktieComboBox = new JComboBox();
			funktieComboBox.setModel(new FunktieComboBoxModel());
			funktieComboBox.setRenderer(new PanelRenderer(30, 200));
			funktieComboBox.addActionListener(new FunktieSelectionListener());
			/// Prepare and execute the query
			boolean hasBegun = SConnection.getConnection().hasBegun();
			if( ! hasBegun ) { SConnection.begin(); }
			SPreparedStatement stmt = Funktie.meta.select(
					"1=1", "seqnr ASC");
			SResultSet res = stmt.execute();
			
			/// loop through the results
			while (res.hasNext()) {
				FunktieBean strt = new FunktieBean(((Funktie)res.getRecord()));
				funktieComboBox.addItem(strt);
			}
			if( ! hasBegun ) { SConnection.commit(); }
			funktieComboBox.getModel().setSelectedItem(funktieComboBox.getItemAt(0));
		}
		return funktieComboBox;
	}

	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setViewportView(getJTable());
		}
		return jScrollPane;
	}

	/**
	 * This method initializes jTable	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private JTable getJTable() {
		if (jTable == null) {
			jTable = new JTable();
			jTable.getSelectionModel().addListSelectionListener(new TableSelectionListener());
// Make column header click result in sorting ascending (shift-click is descending)
	        TableSorter listSorter = new TableSorter();
			JTableHeader th = jTable.getTableHeader();
	        th.addMouseListener(listSorter); 
		}
		return jTable;
	}

	private void getWedstrijd() {
		boolean hasBegun = SConnection.getConnection().hasBegun();
		if( ! hasBegun ) { SConnection.begin(); }
		SPreparedStatement stmt = Procesverbaal.meta.select(
				"1=1", null);
		SResultSet res = stmt.execute();
		if( res.hasNext() ) {
			ProcesverbaalBean wed = new ProcesverbaalBean(((Procesverbaal)res.getRecord()));
			wedId = wed.getWedstrijdid();
			getNaamTextField().setText(wed.getWedstrijdnaam());
			Calendar wedDate = Calendar.getInstance();
			wedDate.setTime(wed.getWedstrijddatum());
			wedDate.add(Calendar.MONTH,1);// Correctie omdat de setTime functie er een maand aftrekt
			getDatumField().setDate(wedDate);
			getOrganisatieTextField().setText(wed.getOrganisatie());
			getZwemwaterTextField().setText(wed.getZwembad());
			getPlaatsTextField().setText(wed.getPlaats());
			getStartMethodeTextField().setText(wed.getStartmethode());
			getBaanLengteTextField().setText(wed.getBaanlengte().toString());
			getTijdMetingTextField().setText(wed.getTijdmeting());
			getAanvangTextField().setText(wed.getAanvang().toString());
			getEindeTextField().setText(wed.getEinde().toString());
			getTempTextField().setText(wed.getWatertemperatuur().toString());
			getOpmerkingenTextArea().setText(wed.getOpmerkingen());
			getWaarnemerTextField().setText(wed.getWaarnemer());
			hasBegun = SConnection.getConnection().hasBegun();
			if( ! hasBegun ) { SConnection.begin(); }
			Connection JDBCcon = SConnection.getBegunDBConnection();
			try {
				Statement stmt1 = JDBCcon.createStatement();
				ResultSet res1 = stmt1.executeQuery("SELECT COUNT(*) as nr FROM start "+
				"WHERE Eindtijd='agmk'");
				if( res1.next() ) {
					getAfwezigMKTextField().setText(res1.getInt("nr")+"");
				}
				res1 = stmt1.executeQuery("SELECT COUNT(*) as nr FROM start "+
				"WHERE Eindtijd='agzk'");
				if( res1.next() ) {
					getAfwezigZKTextField().setText(res1.getInt("nr")+"");
				}
				SConnection.commit();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			//Create the wedstrijd record.
			wedId = 1;
			ProcesverbaalBean wed = new ProcesverbaalBean();
			wed.setWedstrijdid(wedId);
			Calendar c = Calendar.getInstance();
			wed.setWedstrijddatum(c.getTime());
			wed.create();
		}
		if( ! hasBegun ) { SConnection.commit(); }
		
	}
	
	@SuppressWarnings("unchecked")
	private void fillTable(String sortBy, Boolean ascending) {
		List<WedstrijdjuryBean> tmp = new ArrayList<WedstrijdjuryBean>();
		/// Prepare and execute the query
		boolean hasBegun = SConnection.getConnection().hasBegun();
		if( ! hasBegun ) { SConnection.begin(); }
		SPreparedStatement stmt = Wedstrijdjury.meta.select(
				"1=1", sortBy+(ascending.booleanValue()?"":" DESC"));
		SResultSet res = stmt.execute();
		
		/// loop through the results
		while (res.hasNext()) {
			WedstrijdjuryBean strt = new WedstrijdjuryBean(((Wedstrijdjury)res.getRecord()));
			tmp.add(strt);
		}
		if( ! hasBegun ) { SConnection.commit(); }
    	olist = CollectionUtilities.observableList(tmp);
		TableUtilities.setViewToModel("LangebaanModel.xml", "Wedstrijdjury", getJTable(), olist);
		TableColumn col1 = getJTable().getColumnModel().getColumn(0);
		col1.setMinWidth(150);
		col1.setMaxWidth(150);
		TableColumn col2 = getJTable().getColumnModel().getColumn(1);
		col2.setMinWidth(30);
		col2.setMaxWidth(30);
//		TableColumn col3 = getJTable().getColumnModel().getColumn(2);
		TableColumn col4 = getJTable().getColumnModel().getColumn(3);
		col4.setMinWidth(120);
		col4.setMaxWidth(120);
		TableColumn col5 = getJTable().getColumnModel().getColumn(4);
		col5.setMinWidth(80);
		col5.setMaxWidth(80);
	}
	
	private void clearInvoer() {
		getIdTextField().setText(null);
		getNaamJuryTextField().setText(null);
		getPlaatsJuryTextField().setText(null);
		getBevoegdheidTextField().setText(null);
		getBlokNrTextField().setText(null);
	}

	/**
	 * This method initializes clearButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getClearButton() {
		if (clearButton == null) {
			clearButton = new JButton();
			clearButton.setText("Maak leeg");
			clearButton.addActionListener(new ClearButtonActionListener());
		}
		return clearButton;
	}
	   
	class PanelRenderer implements ListCellRenderer	{
		private JPanel renderer;
		private JLabel first;
		private JLabel second;
		
		public PanelRenderer(int firstColumnWidth, int secondColumnWidth) {
			renderer = new JPanel();
			renderer.setLayout(new BoxLayout(renderer, BoxLayout.X_AXIS) );
			first = new JLabel(" ");
			Dimension d1 = first.getPreferredSize();
			d1.width = firstColumnWidth;
			first.setMaximumSize(d1);
			second = new JLabel(" ");
			Dimension d2 = second.getPreferredSize();
			d2.width = secondColumnWidth;
			second.setMaximumSize(d2);
			renderer.add(first );
			renderer.add(second );
		}
	
		public Component getListCellRendererComponent(JList list, Object value,
				int index, boolean isSelected, boolean cellHasFocus) { 
			FunktieBean item = (FunktieBean)value;
			if( item != null ) {
				first.setText( item.getCode() );
				second.setText( item.getNaam() );
			} else {
				first.setText("");
				second.setText("");
			}
			renderer.setBackground(isSelected ? list.getSelectionBackground() : null);
			renderer.setForeground(isSelected ? list.getSelectionForeground() : null);
			return renderer;
		}
	}
	
	/**
	 * This method initializes blokNrTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getBlokNrTextField() {
		if (blokNrTextField == null) {
			blokNrTextField = new JTextField();
		}
		return blokNrTextField;
	}
	
	class FunktieComboBoxModel extends DefaultComboBoxModel {

		private static final long serialVersionUID = 1L;
		
		public void setSelectedItem(FunktieBean f) {
			FunktieBean res = null;
			for (int i=0; i<super.getSize(); i++) {
				FunktieBean fs = (FunktieBean) super.getElementAt(i);
				if( fs.getCode().equals(f.getCode()) ) {
					res = (FunktieBean) super.getElementAt(i);
					break;
				} 
			}
			super.setSelectedItem(res);
		}
	
	}

	/**
	 * This method initializes startKostenButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getStartKostenButton() {
		if (startKostenButton == null) {
			startKostenButton = new JButton();
			startKostenButton.setText("Kosten");
			startKostenButton.addActionListener(new StartKostenActionListener());
		}
		return startKostenButton;
	}

	/**
	 * This method initializes startkostenDialog	
	 * 	
	 * @return javax.swing.JDialog	
	 */
	private JDialog getStartkostenDialog() {
		if (startkostenDialog == null) {
			startkostenDialog = new JDialog();
			startkostenDialog.setSize(new Dimension(407, 290));
			startkostenDialog.setTitle("Startkosten definitie");
			startkostenDialog.setModal(true);
			startkostenDialog.setContentPane(getJContentPane());
		}
		return startkostenDialog;
	}

	/**
	 * This method initializes jContentPane	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getOkCancelPanel(), BorderLayout.SOUTH);
			jContentPane.add(getEntryPanel(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes okCancelPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getOkCancelPanel() {
		if (okCancelPanel == null) {
			GridBagConstraints gridBagConstraints57 = new GridBagConstraints();
			gridBagConstraints57.insets = new Insets(5, 5, 5, 5);
			okCancelPanel = new JPanel();
			okCancelPanel.setLayout(new GridBagLayout());
			okCancelPanel.add(getOkButton(), gridBagConstraints57);
			okCancelPanel.add(getCancelButton(), new GridBagConstraints());
		}
		return okCancelPanel;
	}

	/**
	 * This method initializes entryPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getEntryPanel() {
		if (entryPanel == null) {
			GridBagConstraints gridBagConstraints56 = new GridBagConstraints();
			gridBagConstraints56.fill = GridBagConstraints.BOTH;
			gridBagConstraints56.gridy = 1;
			gridBagConstraints56.weightx = 1.0;
			gridBagConstraints56.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints56.gridwidth = 2;
			gridBagConstraints56.gridx = 1;
			GridBagConstraints gridBagConstraints55 = new GridBagConstraints();
			gridBagConstraints55.fill = GridBagConstraints.BOTH;
			gridBagConstraints55.gridx = 1;
			gridBagConstraints55.gridy = 2;
			gridBagConstraints55.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints55.gridwidth = 2;
			gridBagConstraints55.weightx = 1.0;
			GridBagConstraints gridBagConstraints54 = new GridBagConstraints();
			gridBagConstraints54.fill = GridBagConstraints.BOTH;
			gridBagConstraints54.gridx = 3;
			gridBagConstraints54.gridy = 1;
			gridBagConstraints54.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints54.weightx = 1.0;
			GridBagConstraints gridBagConstraints53 = new GridBagConstraints();
			gridBagConstraints53.fill = GridBagConstraints.BOTH;
			gridBagConstraints53.gridx = 3;
			gridBagConstraints53.gridy = 4;
			gridBagConstraints53.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints53.weightx = 1.0;
			GridBagConstraints gridBagConstraints52 = new GridBagConstraints();
			gridBagConstraints52.fill = GridBagConstraints.BOTH;
			gridBagConstraints52.gridx = 1;
			gridBagConstraints52.gridy = 4;
			gridBagConstraints52.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints52.gridwidth = 2;
			gridBagConstraints52.weightx = 1.0;
			GridBagConstraints gridBagConstraints50 = new GridBagConstraints();
			gridBagConstraints50.fill = GridBagConstraints.BOTH;
			gridBagConstraints50.gridx = 3;
			gridBagConstraints50.gridy = 3;
			gridBagConstraints50.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints50.weightx = 1.0;
			GridBagConstraints gridBagConstraints28 = new GridBagConstraints();
			gridBagConstraints28.fill = GridBagConstraints.BOTH;
			gridBagConstraints28.gridx = 1;
			gridBagConstraints28.gridy = 3;
			gridBagConstraints28.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints28.gridwidth = 2;
			gridBagConstraints28.weightx = 1.0;
			GridBagConstraints gridBagConstraints27 = new GridBagConstraints();
			gridBagConstraints27.fill = GridBagConstraints.BOTH;
			gridBagConstraints27.gridx = 3;
			gridBagConstraints27.gridy = 2;
			gridBagConstraints27.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints27.weightx = 1.0;
			GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
			gridBagConstraints23.fill = GridBagConstraints.BOTH;
			gridBagConstraints23.gridx = 3;
			gridBagConstraints23.gridy = 0;
			gridBagConstraints23.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints23.weightx = 1.0;
			GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
			gridBagConstraints15.fill = GridBagConstraints.BOTH;
			gridBagConstraints15.gridx = 0;
			gridBagConstraints15.gridy = 0;
			gridBagConstraints15.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints15.anchor = GridBagConstraints.EAST;
			gridBagConstraints15.gridwidth = 2;
			gridBagConstraints15.weightx = 1.0;
			entryPanel = new JPanel();
			entryPanel.setLayout(new GridBagLayout());
			entryPanel.add(getLabel1TextField(), gridBagConstraints15);
			entryPanel.add(getValue1TextField(), gridBagConstraints23);
			entryPanel.add(getLabel2TextField(), gridBagConstraints56);
			entryPanel.add(getValue2TextField(), gridBagConstraints54);
			entryPanel.add(getLabel3TextField(), gridBagConstraints55);
			entryPanel.add(getValue3TextField(), gridBagConstraints27);
			entryPanel.add(getLabel4TextField(), gridBagConstraints28);
			entryPanel.add(getValue4TextField(), gridBagConstraints50);
			entryPanel.add(getLabel5TextField(), gridBagConstraints52);
			entryPanel.add(getValue5TextField(), gridBagConstraints53);
		}
		return entryPanel;
	}

	/**
	 * This method initializes okButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getOkButton() {
		if (okButton == null) {
			okButton = new JButton();
			okButton.setText("Ok");
			okButton.setPreferredSize(new Dimension(73, 26));
			okButton.addActionListener(new SaveStartkostenActionListener());
		}
		return okButton;
	}

	/**
	 * This method initializes cancelButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancelButton() {
		if (cancelButton == null) {
			cancelButton = new JButton();
			cancelButton.setText("Cancel");
			cancelButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					getStartkostenDialog().setVisible(false);
				}
				
			});
		}
		return cancelButton;
	}

	/**
	 * This method initializes label1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getLabel1TextField() {
		if (label1TextField == null) {
			label1TextField = new JTextField();
		}
		return label1TextField;
	}

	/**
	 * This method initializes value1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getValue1TextField() {
		if (value1TextField == null) {
			value1TextField = new JTextField();
		}
		return value1TextField;
	}

	/**
	 * This method initializes label1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getLabel2TextField() {
		if (label2TextField == null) {
			label2TextField = new JTextField();
		}
		return label2TextField;
	}

	/**
	 * This method initializes value1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getValue2TextField() {
		if (value2TextField == null) {
			value2TextField = new JTextField();
		}
		return value2TextField;
	}

	/**
	 * This method initializes label1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getLabel3TextField() {
		if (label3TextField == null) {
			label3TextField = new JTextField();
		}
		return label3TextField;
	}

	/**
	 * This method initializes value1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getValue3TextField() {
		if (value3TextField == null) {
			value3TextField = new JTextField();
		}
		return value3TextField;
	}

	/**
	 * This method initializes label1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getLabel4TextField() {
		if (label4TextField == null) {
			label4TextField = new JTextField();
		}
		return label4TextField;
	}

	/**
	 * This method initializes value1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getValue4TextField() {
		if (value4TextField == null) {
			value4TextField = new JTextField();
		}
		return value4TextField;
	}

	/**
	 * This method initializes label1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getLabel5TextField() {
		if (label5TextField == null) {
			label5TextField = new JTextField();
		}
		return label5TextField;
	}

	/**
	 * This method initializes value1TextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getValue5TextField() {
		if (value5TextField == null) {
			value5TextField = new JTextField();
		}
		return value5TextField;
	}
}  //  @jve:decl-index=0:visual-constraint="10,10"
